//
//  XDMyInvestmentCell.m
//  xindailianmeng
//
//  Created by 张东 on 2017/2/8.
//  Copyright © 2017年 xindailianmeng.cn. All rights reserved.
//

#import "XDMyInvestmentCell.h"
#import "XDMyInvestmentModel.h"
#import "ZHRTBasicMethod.h"
@interface XDMyInvestmentCell ()
// 封闭期限 约束
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *timeDeaLbLayout;
//"name":"新贷灵活",         String标的名称
@property (weak, nonatomic) IBOutlet UILabel *nameLb;

//"inMoney":1020.00,       double 投资金额
@property (weak, nonatomic) IBOutlet UILabel *inMoneyLb;
//"limitTime":1,              int投资期限
//"limitType":"月",            String投资期限类别
@property (weak, nonatomic) IBOutlet UILabel *limitLb;

//"inTime":1483942647000,  String 投资时间
@property (weak, nonatomic) IBOutlet UILabel *inTimeLb;

//"investId":17,              Long 投资id
//"limitTime":1,              int投资期限
//"limitType":"月",            String投资期限类别

//"payTime":1486707447000, String到期时间
@property (weak, nonatomic) IBOutlet UILabel *payTimeLb;

//"planEarnings":6.49,        double收益
@property (weak, nonatomic) IBOutlet UILabel *planEarningsLb;

//"yearRate":7.50,            double 年利率
//"couponMoney":20.00,     double 卡卷面值
@property (weak, nonatomic) IBOutlet UILabel *couponMoneyLb;

//"voucherType":2，          int     卡卷类别
//(1-现金券、2-加息券、3-收益卡、4-体验金、5-红包、6-积分、7-充值卡：后期可能抽取出去, voucherType 不存在的时候就是没有使用优惠卷，卡卷面值包括现金卷，加息卷面值，默认0)
//"isMulti":"0"              String 标的类别(暂时用不上)
//(标的分类 0-优选计划 1-新贷散标 2-稳赢通(新手专享)  3-活动计划 4-加息活动 5-新贷宝)
//}
//],
//"totalPages":1              int总页数

@end

@implementation XDMyInvestmentCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self = [[NSBundle mainBundle] loadNibNamed:@"XDMyInvestmentCell" owner:self options:nil].firstObject;
    }
    return self;
}
- (void)layoutSubviews {
    if (IsIphone5 || IsIphone4) {
        self.timeDeaLbLayout.constant = 20;
    }else if(IsIphone6P) {
       self.timeDeaLbLayout.constant = 60;
    }
    
}
- (void)setModel:(XDMyInvestmentModel *)model {
    self.nameLb.text = model.name;
    self.inMoneyLb.text = [ZHRTBasicMethod ChangeNumberFormat:[NSString stringWithFormat:@"%.2f", model.inMoney]];
    if ([model.limitType isEqualToString:@"月"]) {
        self.limitLb.text = [NSString stringWithFormat:@"%zd个%@", model.limitTime, model.limitType];
    } else {
        self.limitLb.text = [NSString stringWithFormat:@"%zd%@", model.limitTime, model.limitType];
    }
    self.planEarningsLb.text = [NSString stringWithFormat:@"%.2f",model.planEarnings];
    self.inTimeLb.text = [NSString stringWithFormat:@"投资时间 %@",model.inTime];
     self.payTimeLb.text = [NSString stringWithFormat:@"到期时间 %@",model.payTime];
    if (model.voucherType == 1) {
        self.couponMoneyLb.text = [NSString stringWithFormat:@"(含%@元现金券)",[ZHRTBasicMethod effectiveFigure:model.couponMoney]];
    }

}
@end
